﻿using System;

namespace Klinkby
{
    [Serializable]
    public class Tuple<T0, T1> : IEquatable<Tuple<T0, T1>>
    {
        readonly T0 _item0;
        readonly T1 _item1;
        internal Tuple(T0 item0, T1 item1)
        {
            _item0 = item0;
            _item1 = item1;
        }

        public T0 Item0
        {
            get { return _item0; }
        }

        public T1 Item1
        {
            get { return _item1; }
        }

        public bool Equals(Tuple<T0, T1> other)
        {
            if (object.ReferenceEquals(other, null))
                return false;
            return !object.ReferenceEquals(_item0, null)
                ? _item0.Equals(other._item0)
                : object.ReferenceEquals(other._item0, null)
                &&
                !object.ReferenceEquals(_item1, null)
                ? _item1.Equals(other._item1)
                : object.ReferenceEquals(other._item1, null);
        }
        public override bool Equals(object obj)
        {
            var t = obj as Tuple<T0,T1>;
            return this == t;
        }
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
        public override string ToString()
        {
            return string.Format("({0}, {1})", _item0, _item1);
        }

    }
}
